package com.hsxc.cdz.monitor.bean.server.v1_21;

import com.hsxc.cdz.base.util.BytesUtil;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.ReferenceCountUtil;

public class RateSettingSerMsg extends ServerMessage {

	/********************************************************/
	//对象私有属性
	private int oneRate;
	private int twoRate;
	private int threeRate;
	private int fourRate;
	private int serviceFee;
	private String timeRate;
	
	public static final int length = 58;
	/********************************************************/
	//get() and set()
	public int getOneRate() {
		return oneRate;
	}

	public void setOneRate(int oneRate) {
		this.oneRate = oneRate;
	}

	public int getTwoRate() {
		return twoRate;
	}

	public void setTwoRate(int twoRate) {
		this.twoRate = twoRate;
	}

	public int getThreeRate() {
		return threeRate;
	}

	public void setThreeRate(int threeRate) {
		this.threeRate = threeRate;
	}

	public int getFourRate() {
		return fourRate;
	}

	public void setFourRate(int fourRate) {
		this.fourRate = fourRate;
	}

	public int getServiceFee() {
		return serviceFee;
	}

	public void setServiceFee(int serviceFee) {
		this.serviceFee = serviceFee;
	}

	public String getTimeRate() {
		return timeRate;
	}

	public void setTimeRate(String timeRate) {
		this.timeRate = timeRate;
	}

	/***********************************************************/
	//继承父类方法
	@Override
	public byte[] getBytesFromMessage() {
		ByteBuf bytes = Unpooled.buffer(length);
		byte[] result;
		byte[] temp;
		temp  = BytesUtil.intToBytesDesc(this.getOneRate(), 2);
		bytes.writeBytes(temp);
		
		temp  = BytesUtil.intToBytesDesc(this.getTwoRate(), 2);
		bytes.writeBytes(temp);
		
		temp  = BytesUtil.intToBytesDesc(this.getThreeRate(), 2);
		bytes.writeBytes(temp);
		
		temp  = BytesUtil.intToBytesDesc(this.getFourRate(), 2);
		bytes.writeBytes(temp);
		
		temp  = BytesUtil.intToBytesDesc(this.getServiceFee(), 2);
		bytes.writeBytes(temp);
		String timeRate=this.getTimeRate();
		String trueTimeRate = "";
		for(int i=0;i<timeRate.length();i++){
			String t ="0"+timeRate.charAt(i);
			trueTimeRate+=t;
		}
		temp  = BytesUtil.strToBinBytes(trueTimeRate, 48);
		bytes.writeBytes(temp);
		
		result = new byte[bytes.readableBytes()];
		bytes.readBytes(result);
		ReferenceCountUtil.release(bytes);
		return result;
	}
}
